package com.qj.yantaishan.controller;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qj.yantaishan.common.core.domain.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qj.yantaishan.common.annotation.Log;
import com.qj.yantaishan.common.enums.BusinessType;
import com.qj.yantaishan.domain.Comment;
import com.qj.yantaishan.service.ICommentService;
import com.qj.yantaishan.common.core.controller.BaseController;
import com.qj.yantaishan.common.core.domain.AjaxResult;
import com.qj.yantaishan.common.utils.poi.ExcelUtil;
import com.qj.yantaishan.common.core.page.TableDataInfo;

/**
 * 评论Controller
 *
 * @author qihe
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/yantaishan/Comment")
public class CommentController extends BaseController {
    private String prefix = "yantaishan/Comment" ;
    @Autowired
    private ICommentService commentService;
    @GetMapping("list")
    public R getCommentList(
            @RequestParam(required = false, defaultValue = "1") Integer currentPage,
                            @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
        Map<String, Object> result = commentService.mySelectCommentList(currentPage, pageSize);
        return R.ok(result);
    }
    @PutMapping
    public R modifyCommentStatus(@RequestParam(required = true) Integer cid,
                                 @RequestParam(required = true) Integer status) {
        commentService.update(new LambdaUpdateWrapper<Comment>().set(Comment::getStatus, status).eq(Comment::getId, cid));
        return R.ok();
    }

    @DeleteMapping
    public R deleteCommentStatus(@RequestParam(required = true) Integer cid) {
        commentService.update(new LambdaUpdateWrapper<Comment>().set(Comment::getDeleteFlg, 1).eq(Comment::getId, cid));
        return R.ok();

    }
}
